<?php
//***************  add by code   ******************
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of article
 *
 * @author Administrator
 */
class news extends CI_Controller {

    private $page_size=10;

    public function __construct() {
        parent::__construct();
        $this->url = $this->uri->segments;
        $this->CI = & get_instance();
    }

    public function index() {
        $g_nav_list = $this->CI->load->get_var('g_nav_list');//获取导航
        $url_info = $this->url;
        $action = $url_info[2];
        $data['action_info'] = $this->m_public->getRowInfo('class',array('classlinkname'=>$action));
        $data['child_info'] = $this->m_public->getAllInfo('class',array('parentid'=>$data['action_info']['classid']));
        foreach($data['child_info'] as $key=>$val){
            $condition['from'] = 'article';
            $condition['where'] = array('classid'=>$val['classid']);
            $condition['limit'] = 3;
            $condition['offset'] = 0;
            $condition['order'] = 'addtime desc';
            $data['child_info'][$key]['article_list'] = $this->m_public->get_list($condition);
        }

        /*SEO部分*/
        if(isset($data['action_info']['seotitle']) && !empty($data['action_info']['seotitle']))
            $data['g_site']['websitename'] = $data['action_info']['seotitle'];
        if(isset($data['action_info']['keywords']) && !empty($data['action_info']['keywords']))
            $data['g_site']['websitekeywords'] = $data['action_info']['keywords'];
        if(isset($data['action_info']['description']) && !empty($data['action_info']['description']))
            $data['g_site']['websitedescription'] = $data['action_info']['description'];

        /*右侧部分，产品*/
        $condition['from'] = 'class';
        $condition['where'] = array(
            'classpropertyid' => 20,
            'configid' => CONFIG_ID,
            //'parentid' => 3
        );
        $condition['limit'] = 3;
        $condition['offset'] = 0;
        $condition['order'] = 'listid';
        $data['products'] = $this->m_public->get_list($condition);

        /*右侧部分，联系我们*/
        $contact_config = $this->m_public->getRowInfo('config',array('configid'=>CONFIG_ID),'contact_config');
        $data['contact'] = json_decode($contact_config['contact_config'],true);

        /*头部,底部数据*/
        $config = $this->m_public->getRowInfo('config',array('configid'=>CONFIG_ID),'copyright,banquan,contact_config,footerinfo');
        $config['contact_config'] = json_decode($config['contact_config'],true);
        $data['config'] = $config;
        $footer_condition = array(
            'from' => 'link',
            'where' => array('isclose'=>0,'typeid'=>1,'configid'=>CONFIG_ID),
            'order' => 'listid'
        );
        $data['footer_info'] = $this->m_public->get_list($footer_condition);

        $this->load->view('template_news_cate',$data);
    }
}
